﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CodeGeneratorBootstrap.ProjectServices;

namespace CodeGeneratorBootstrap.Models
{
    public class ProjectModel
    {
        public int ProjectId { get; set; }
        public String ProjectName { get; set; }

        public ProjectTypeModel Style { get; set; }
        public int Platform { get; set; }
        public String DbServerName { get; set; }
        public String DbName { get; set; }
        public String DbUserName { get; set; }
        public String DbPassword { get; set; }
        public int Version { get; set; }
        public DateTime CreateDate { get; set; }
        public DateTime LastUpdate { get; set; }
        public bool PreselectedSearch { get; set; }
        public bool RBAC { get; set; }

        public ProjectModel() { }

        internal ProjectModel(ProjectDto dto)
        {
            this.ProjectId = dto.Id;
            this.ProjectName = dto.Name;
            this.CreateDate = dto.CreateTime;
            this.DbServerName = dto.DbServerName;
            this.DbName = dto.DbName;
            this.DbUserName = dto.DbUserName;
            this.DbPassword = dto.DbPassword;
            this.LastUpdate = dto.LastUpdate;
            this.RBAC = dto.RBAC;
            this.PreselectedSearch = dto.PreselectedSearch;
            this.Version = dto.Version;
            this.Style = new ProjectTypeModel(dto.Style);
        }

        public CodeGeneratorBootstrap.Models.ProjectModel ToProjectModel()
        {
            return new ProjectModel
            {
                ProjectId = this.ProjectId,
                ProjectName = this.ProjectName,
                CreateDate=  this.CreateDate,
                DbServerName = this.DbServerName,
                DbName = this.DbName,
                DbUserName = this.DbUserName,
                DbPassword = this.DbPassword,
                LastUpdate = this.LastUpdate,
                RBAC = this.RBAC,
                Style =  this.Style,
                PreselectedSearch = this.PreselectedSearch,
                Version = this.Version,    
            };
        }

    }
}
